<?php include "../public/header.php";?>
<?php include "../public/header_edit.php";?>
<link rel="stylesheet" type="text/css" href="/static/component/laytp/module/cityPicker/city-picker.css">

<body id="optPage">
<form class="layui-form layui-form-pane" id="commentForm">
    <div class="page-title"><div class="page-title-con"><span id="flowsetname"></span><div class="move_title"></div><?php include "../public/subturn.php";?></div></div>
    <div class="main-container">
        <div class="block-generic">
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">申请人</label>
                        <div class="layui-input-block">
                            <input type="text" id="flowuser" readonly placeholder="请输入" autocomplete="off" class="layui-input readonly">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">申请部门</label>
                        <div class="layui-input-block">
                            <input type="text" id="flowdept" readonly placeholder="请输入" autocomplete="off" class="layui-input readonly">
                        </div>
                    </div>
                </div>
            </div>


            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits"><span>基本信息</span></div>
                </div>
            </div>


            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label"><text>*</text>项目名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="name" id="name" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">项目编号</label>
                        <div class="layui-input-block">
                            <input type="text" name="number" id="number" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">项目类型</label>
                        <div class="layui-input-block">
                            <div id="bidtype"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">项目所在地</label>
                        <div class="layui-input-block" style="z-index: 1;">
                            <input type="text" name="areas" id="areas" placeholder="请选择" readonly clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">项目地址</label>
                        <div class="layui-input-block">
                            <input type="text" name="addr" id="addr" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">招标方</label>
                        <div class="layui-input-block">
                            <input type="text" name="zhaoname" id="zhaoname" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">招标方联系方式</label>
                        <div class="layui-input-block">
                            <input type="text" name="zhaotel" id="zhaotel" placeholder="请输入"  clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">预计合同金额(万元)</label>
                        <div class="layui-input-block">
                            <input type="text" id="yufee" name="yufee" placeholder="请输入" clearable autocomplete="off" class="layui-input moneyinput6">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">招标方式</label>
                        <div class="layui-input-block">
                            <div id="zhaotype"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>项目所属单位</label>
                        <div class="layui-input-block">
                            <div class="tanxian">
                                <div class="tanxianclick" onclick="openPage('../public/choose_userpart.php?dom=chanid&type=dept&dept=chan&single=1','770px','490px');"></div>
                                <div class="tanxiannei" id="chanid"></div>
                            </div>
                            <div class="tancheckdiv"><div class="tancheck" onclick="openPage('../public/choose_userpart.php?dom=chanid&type=dept&dept=chan&single=1','770px','490px');"><i class="layui-icon layui-icon-search"></i></div></div>
                            <div id="chanid_tanerror" class="tanerrormsg"></div>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>项目属性</label>
                        <div class="layui-input-block ">
                            <select id="business" name="business" lay-filter="business">
                                <option value="">请选择</option>
                                <option value="1">自营</option>
                                <option value="2">联营</option>
                            </select>
                            <p class="error" id="business_error" style="margin: 0;"></p>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">经营备案人</label>
                        <div class="layui-input-block">
                            <input type="text" name="jingbeier" id="jingbeier" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">信息来源</label>
                        <div class="layui-input-block">
                            <input type="text" name="xinlai" id="xinlai" placeholder="请输入"  clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>




            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">报名截止时间</label>
                        <div class="layui-input-block">
                            <input type="text" name="enddt_bao" id="enddt_bao" readonly placeholder="请选择" clearable  autocomplete="off" class="layui-input bdate_ymdhi">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>投标截止时间</label>
                        <div class="layui-input-block">
                            <input type="text" name="enddt_tou" id="enddt_tou" readonly placeholder="请选择" clearable  autocomplete="off" class="layui-input bdate_ymdhi">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">开标时间</label>
                        <div class="layui-input-block">
                            <input type="text" name="kaidt" id="kaidt" readonly placeholder="请选择" clearable  autocomplete="off" class="layui-input bdate_ymdhi">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>投标负责人</label>
                        <div class="layui-input-block">
                            <div class="tanxian">
                                <div class="tanxianclick" onclick="openPage('../public/choose_userpart.php?dom=touer&type=user&single=1', '770px', '490px');"></div>
                                <div class="tanxiannei" id="touer"></div>
                            </div>
                            <div class="tancheckdiv"><div class="tancheck" onclick="openPage('../public/choose_userpart.php?dom=touer&type=user&single=1', '770px', '490px');"><i class="layui-icon layui-icon-search"></i></div></div>
                            <div id="touer_tanerror" class="tanerrormsg"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>投标单位</label>
                        <div class="layui-input-block">
                            <div class="tanxian">
                                <div class="tanxianclick" onclick="openPage('../public/choose_userpart.php?dom=touunit&type=dept&dept=chan&single=1','770px','490px');"></div>
                                <div class="tanxiannei" id="touunit"></div>
                            </div>
                            <div class="tancheckdiv"><div class="tancheck" onclick="openPage('../public/choose_userpart.php?dom=touunit&type=dept&dept=chan&single=1','770px','490px');"><i class="layui-icon layui-icon-search"></i></div></div>
                            <div id="touunit_tanerror" class="tanerrormsg"></div>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">参投说明</label>
                        <div class="layui-input-block">
                            <input type="text" name="toushuo" id="toushuo" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div id="business_lian" class="layui-hide">
                <div class="layui-form-item">
                    <div class="layui-row layui-col-space10">
                        <div class="layui-col-md6">
                            <label class="layui-form-label"><text>*</text>联营单位</label>
                            <div class="layui-input-block">
                                <input type="text" readonly name="lianunit" class="layui-input lianunit" onclick="openPage('../public/choose_dealcom.php?dom=lianunit','80%','80%')">
                                <div class="choose_div" id="lianunit" key="1"></div>
                                <span class="choose_one" onclick="openPage('../public/choose_dealcom.php?dom=lianunit','80%','80%')"><i class="layui-icon layui-icon-search"></i></span>
                            </div>
                        </div>
                        <div class="layui-col-md6">
                            <label class="layui-form-label"><text>*</text>是否收费</label>
                            <div class="layui-input-block">
                                <select id="isfei" name="isfei" lay-filter="isfei">
                                    <option value="">请选择</option>
                                    <option value="是">是</option>
                                    <option value="否">否</option>
                                </select>
                                <p class="error" id="isfei_error" style="margin: 0;"></p>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-row layui-col-space10">
                        <div class="layui-col-md12">
                            <label class="layui-form-label">费用收取说明</label>
                            <div class="layui-input-block">
                                <input type="text" name="feishuo" id="feishuo" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                            </div>
                        </div>
                    </div>
                </div>
            </div>


            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea">项目概况</label>
                        <div class="layui-input-block">
                            <textarea id="gai" name="gai" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea">备注</label>
                        <div class="layui-input-block">
                            <textarea id="explain" name="explain" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">关联单据</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="flowrelas" class="layui-input flowrelas" onclick="openPage('../public/choose_flowrelas.php?dom=flowrelas','80%','80%');">
                            <div class="choose_div" id="flowrelas" key="1"></div>
                            <span class="choose_one" onclick="openPage('../public/choose_flowrelas.php?dom=flowrelas','80%','80%');"><i class="layui-icon layui-icon-search"></i></span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-hide" id="advanersDiv">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">预审人</label>
                        <div class="layui-input-block relative">
                            <div class="tanxian">
                                <div class="tanxianclick" onclick="openPage('../public/choose_userpart.php?dom=advaners&type=user&single=2','770px','490px');"></div>
                                <div class="tanxiannei" id="advaners"></div>
                            </div>
                            <div class="tancheckdiv"><div class="tancheck" onclick="openPage('../public/choose_userpart.php?dom=advaners&type=user&single=2','770px','490px');"><i class="layui-icon layui-icon-search"></i></div></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-hide" id="nexterDiv">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label"><text>*</text>指定下一步审核人</label>
                        <div class="layui-input-block relative">
                            <div class="tanxian">
                                <div class="tanxianclick" onclick="openPage('../public/choose_userpart.php?dom=nexter&type=user&single=1','770px','490px');"></div>
                                <div class="tanxiannei" id="nexter"></div>
                            </div>
                            <div class="tancheckdiv"><div class="tancheck" onclick="openPage('../public/choose_userpart.php?dom=nexter&type=user&single=1','770px','490px');"><i class="layui-icon layui-icon-search"></i></div></div>
                        </div>
                    </div>
                </div>
            </div>
            <?php include '../public/upinfo.php'?>

        </div>
    </div>
</form>
<script>
    var param_poolid = getQueryVariable('poolid') || 0;

    $("#commentForm").validate({
        rules: {
            name: {required: true},
            enddt_tou: {required: true},
        },
        messages:{
            name: {required: "请输入"},
            enddt_tou: {required: "请选择"},
        }
    });


    layui.use(['laytp', 'form'], function() {
        var form = layui.form, layer = layui.layer;
        render_input_attr();

        facade.ajax({type: 'get', url: ask_flowdata_add_bid, data:{poolid:param_poolid}}).done(function(res){
            if (res.code === 2000) {
                var data = res.data;
                $("#flowsetname").text(data.flowsetname);
                $("#flowuser").val(data.flowuser);
                $("#flowdept").val(data.flowdept);
                if(data.isadvan){
                    $("#advanersDiv").removeClass('layui-hide');
                }
                if(data.isnext){
                    $("#nexterDiv").removeClass('layui-hide');
                }

                var poolinfo = res.data.poolinfo || '';
                if(poolinfo){
                    $('#name').val(poolinfo.name);
                    $('#number').val(poolinfo.number);
                    $('#addr').val(poolinfo.addr);
                    $('#zhaoname').val(poolinfo.zhaoname);
                    $('#zhaotel').val(poolinfo.zhaotel);
                    $('#yufee').val(poolinfo.yufee);
                    $('#business').val(poolinfo.business);
                    $('#jingbeier').val(poolinfo.jingbeier);
                    $('#xinlai').val(poolinfo.xinlai);
                    $('#gai').val(poolinfo.gai);
                    $('#explain').val(poolinfo.explain);

                    if(poolinfo.chanid_info.length > 0){
                        tan_tags_init('#chanid', poolinfo.chanid_info);
                    }

                    if(poolinfo.business == 2){
                        $("#business_lian").removeClass('layui-hide');
                    }else{
                        $("#business_lian").addClass('layui-hide');
                    }

                    $("#areas").val(poolinfo.areas);
                    load_areas('areas', res.data.areas, 3);

                    xmselect_dan('bidtype', res.data.bidtype, poolinfo.bidtype);
                    xmselect_dan('zhaotype', res.data.zhaotype, poolinfo.zhaotype);
                    public_upload_file_load('upload_files', res.data.files);
                }else{
                    load_areas('areas', res.data.areas, 3);
                    xmselect_dan('bidtype', res.data.bidtype, '');
                    xmselect_dan('zhaotype', res.data.zhaotype, '');
                    public_upload_file_load('upload_files');
                }






                render_date();
                render_from();
                initParseMoney();
            }
        });

        form.on('select(business)', function(data){
            if(data.value == 2){
                $("#business_lian").removeClass('layui-hide');
            }else{
                $("#business_lian").addClass('layui-hide');
            }

            if(data.value == ''){
                $('#business_error').show().text('请选择');
                $('#business_error').parent().find('input').addClass('select_error');
            }else{
                $('#business_error').hide();
                $('#business_error').parent().find('input').removeClass('select_error');
            }
        });

        form.on('select(isfei)', function(data){
            if(data.value == ''){
                $('#isfei_error').show().text('请选择');
                $('#isfei_error').parent().find('input').addClass('select_error');
            }else{
                $('#isfei_error').hide();
                $('#isfei_error').parent().find('input').removeClass('select_error');
            }
        });



        form.on('submit(add)', function(data){
            data.field.isturn = $(this).attr('key') || 0;
            data.field.flowrelas = get_choose_val('flowrelas');
            data.field.advaners = tan_tags_getvalue("#advaners", 'user');
            data.field.nexter = tan_tags_getvalue("#nexter", 'user');
            data.field.touer = tan_tags_getvalue("#touer", 'user');
            data.field.chanid = tan_tags_getvalue("#chanid", 'dept');
            data.field.touunit = tan_tags_getvalue("#touunit", 'dept');
            data.field.lianunit = get_choose_val('lianunit');



            if(data.field.isturn > 0){
                var validRes = $("#commentForm").valid();

                if(!data.field.chanid){
                    $("#chanid").parents('.tanxian').addClass('tanerror');
                    $('#chanid_tanerror').text('请选择');
                    validRes = false;
                }else{
                    $("#chanid").parents('.tanxian').removeClass('tanerror');
                    $('#chanid_tanerror').text('');
                }

                if(!data.field.touer){
                    $("#touer").parents('.tanxian').addClass('tanerror');
                    $('#touer_tanerror').text('请选择');
                    validRes = false;
                }else{
                    $("#touer").parents('.tanxian').removeClass('tanerror');
                    $('#touer_tanerror').text('');
                }

                if(!data.field.touunit){
                    $("#touunit").parents('.tanxian').addClass('tanerror');
                    $('#touunit_tanerror').text('请选择');
                    validRes = false;
                }else{
                    $("#touunit").parents('.tanxian').removeClass('tanerror');
                    $('#touunit_tanerror').text('');
                }

                if(data.field.business == ''){
                    $('#business_error').show().text('请选择');
                    $('#business_error').parent().find('input').addClass('select_error');
                    validRes = false;
                }else{
                    $('#business_error').hide();
                    $('#business_error').parent().find('input').removeClass('select_error');
                }

                if(data.field.business == 2){
                    formValid('lianunit');
                    if(data.field.lianunit == undefined || !data.field.lianunit){
                        validRes = false;
                    }

                    if(data.field.isfei == ''){
                        $('#isfei_error').show().text('请选择');
                        $('#isfei_error').parent().find('input').addClass('select_error');
                        validRes = false;
                    }else{
                        $('#isfei_error').hide();
                        $('#isfei_error').parent().find('input').removeClass('select_error');
                    }
                }
                if(!validRes){return false;}
            }



            data = parseMoney(data);
            data.field.poolid = param_poolid;
            data.field.files = public_upload_file_value('upload_files');
            public_flow_submit(data.field, ask_flowdata_add_bid, ask_flowdata_edit_bid, $(this).attr('but'));
            return false;
        });

    });

</script>
</body>
</html>
